package com.itheima_17;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class FileToArrayListDemo {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("/Users/oscar/Desktop/HQWork/学习资料/code/mySimpleDateFormat/student.txt"));

        ArrayList<Student> arrayList = new ArrayList<Student>();

        String line;
        while ((line = br.readLine()) != null) {
            String[] split = line.split(",");

            Student student = new Student();
            student.setId(split[0]);
            student.setName(split[1]);
            student.setAge(split[2]);
            student.setAddress(split[3]);

            arrayList.add(student);
        }

        br.close();

        for (Student s : arrayList) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(s.getId()).append(",").append(s.getName()).append(",").append(s.getAge()).append(",").append(s.getAddress());
            System.out.println(stringBuilder.toString());
        }
    }
}
